<?php defined('SYSPATH') OR die('No direct access allowed.');

class Acl_Assert_Check implements Acl_Assert_Interface {

	protected $arguments;

	public function __construct($arguments)
	{
		$this->arguments = $arguments;
	}

	public function assert(Acl $acl, $role = null, $resource = null, $privilege = null)
  {
		foreach($this->arguments as $role_method => $resource_key)
		{
			if (! method_exists($role, $role_method))
				return FALSE;
			if(! $role->$role_method($resource->$resource_key))
				return FALSE;
		}

		return TRUE;
  }
}